<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:replace="dashboard/header :: header"></head>

<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="operlog-form">
					<div class="select-list">
						<ul>
							<li>
								<label>应用名称  </label> <input type="text" name="condition[applicationName|like]"/>
							</li>
							<li>
								<a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()">
	                <i class="fa fa-plus"></i> 新增
	            </a>
	            <a class="btn btn-warning" onclick="$.table.exportExcel()">
		            <i class="fa fa-download"></i> 导出
		        </a>
	        </div>
	        
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	
	<footer th:replace="dashboard/footer :: footer"></footer>

	<script>
		$(function() {
		    var options = {
		        url: ctx+"portal/ucenter/project/datatables" ,
		        createUrl: ctx + 'portal/ucenter/project/add' ,
		        updateUrl: ctx+"portal/ucenter/project/modify?id={id}" ,
		        statusUrl: ctx+"portal/ucenter/project/changeStatus?id={id}" , 
		        cleanUrl: ctx+"portal/ucenter/project/cleanAll",
		        detailUrl: ctx+"portal/ucenter/project/detail?id={id}",
		        removeUrl: ctx+"portal/ucenter/project/delete" ,
		        exportUrl: ctx+"portal/ucenter/project/exportExcel",
		        sortName: "operTime",
		        uniqueId:"id" ,
		        sortOrder: "desc",
		        modalName: "项目",
		        escape: true,
		        showPageGo: true,
		        rememberSelected: true,
		        columns: [{field: 'state',checkbox: true },
			        {field: 'applicationIcons', title: '图标' , width:'60px',  align: 'center',  formatter: function(value, row, index) {
			                var actions = [];
			                actions.push('<img src="'+value+'" class="project-icons-list" aria-hidden="true"></i>');
			                return actions.join('');
			          }
			        },
			        {field: 'applicationName', title: '应用名称'},
			        {field: 'applicationDesc', title: '应用描述'},
			        {field: 'id', title: '菜单功能', align: 'center',  formatter: function(value, row, index) {
			                var actions = [];
			                actions.push('<a href="javascript:$.operate.detail(\'' + row.id + '\')"><i class="fa fa-leaf" aria-hidden="true"> 查看功能 </a>');
			                return actions.join('');
			          }
			        },
			        {field: 'hasStatusLabel', title: '状态', align: 'center',  formatter:function(value,row,index){ return $.table.status(value , row);}},
			        {field: 'addTime', title: '添加时间', sortable: true},
			        {field: 'id' , title: '操作',  align: 'center',  formatter: function(value, row, index) {
			                var actions = [];
			                
			                actions.push('<a class="btn btn-warning btn-xs" onclick="buildMenus(\''+row.id+'\',\''+row.applicationName+'\')"> <i class="fa fa-edit"></i> 功能</a> ');
			                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
			                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="far fa-trash-alt"></i>删除</a> ');
			                
			                // actions.push('<a class="btn btn-info btn-xs ' + resetPwdFlag + '" href="javascript:void(0)" onclick="resetPwd(\'' + row.id + '\')"><i class="fa fa-key"></i>重置</a>');

			                return actions.join('');
			          }
			     }]
		    };
		    $.table.init(options);
		});
		
		// 构建菜单
		function buildMenus(_id,_name) {
			// window.location.href=ctx + 'portal/ucenter/project/menus?applicationId=' + _id ; 
			$.modal.openTab('编辑['+_name+']菜单 ' , ctx + 'portal/ucenter/project/menus?applicationId=' + _id)	
			/*
			var width = ($(window).width() - 200);
        	var height = ($(window).height() - 100);
        	
			var options = {
				title : '菜单管理', 
				width: width , 
				height: height , 
				url : ctx + 'portal/ucenter/project/menus?applicationId=' + _id,
				btn : false
			};
			$.modal.openOptions(options);
			*/ 
		}
	</script>
</body>
</html>